package co.com.services.consultorio;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.ConsultorioDTO;
import co.com.smart.session.DelegateContextEJB;


@Path("/SmartConsultorioServices")
public class ConsultorioServices {
	@GET
	@Path("/getAllConsultorio")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getConsultorio() throws NamingException {
		return Response.ok(DelegateContextEJB.getConsultorioBeanLocal().consultarAllConsultorio())
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@POST
	@Path("/getConsultorioId")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getConsultorioId(ConsultorioDTO json) throws NamingException {
		return Response.ok(DelegateContextEJB.getConsultorioBeanLocal().consultarConsultorioId(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/setConsultorio")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setConsultorio( ConsultorioDTO json){ 
		return Response.ok(DelegateContextEJB.getConsultorioBeanLocal().insertarConsultorio(json))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
				.build();
	}

	@PUT
	@Path("/editConsultorio")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setEditConsultorio(ConsultorioDTO json){ 
		return Response.ok(DelegateContextEJB.getConsultorioBeanLocal().editConsultorio(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/removeConsultorio")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setRemoveConsultorio(ConsultorioDTO json){ 
		return Response.ok(DelegateContextEJB.getConsultorioBeanLocal().removeConsultorio(json, true))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}



}
